<?php
	require_once '../tools/DAO.php';
	session_start();
	
class Clogin {
	
	public function index(){
		header("Location:../View/Vlogin.php");
		$dao = new DAO();
		$aUser = new Joueur();
		
		
			
			if(!empty($_POST["user"]) && !empty($_POST["mdp"])){
				$user = $_POST["user"];
				$mdp = $_POST["mdp"];
				
				$user = $dao->find(null, null, " login=".$user." AND password=".$mdp);

				if(!empty($user)){
					$_SESSION['idjoueur'] = $user->id;
					$aUser->getLogin($user->login);
					$aUser->getLogin($user->idmonde);
					$aUser->getLogin($user->nom);
					$aUser->getLogin($user->prenom);
					$aUser->getLogin($user->mail);
					$aUser->getLogin($user->niveau);
				}
				else{
					header("Location:../View/Vlogin.php");
				}
			
		}
		
		header("Location:../View/Vjoueur.php");
	}
}